FROM node:lts-alpine as build-stage
# 镜像的元信息,maintainer项目维护者
LABEL maintainer="LDJsoCool@163.com"
MAINTAINER jaden.luo <LDJsoCool@163.com>
WORKDIR /app

COPY . .

# 安装cnpm
RUN npm install cnpm -g --no-progress --registry=https://registry.npm.taobao.org
# 安装项目依赖并打包
RUN yarnpkg install --no-progress && yarnpkg run build

FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
#COPY --from=build-stage /app/default.conf /etc/nginx/conf.d/default.conf
# 使用--from把上面产生的静态文件复制到nginx的运行目录
#COPY --from=build-stage /app/dist /usr/share/nginx/html
# nginx容器内部暴露的端口
EXPOSE 80
# 运行的命令
#CMD ["nginx", "-g", "daemon off;"]